#ifndef FUNCTION
#define FUNCTION

class Function {
public:
    virtual double operator() (double x) const = 0;
    virtual double derivative(double x) const {
        const double h = 1e-5; // 差分法估计导数值，h选一个足够小的步长
        return ((*this)(x + h) - (*this)(x - h)) / (2 * h);
    }
};

#endif